
package com.hlkj.pay.vo.order.resp.export;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import java.math.BigDecimal;
import java.util.List;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableField;
import com.hlkj.pay.app.merchant.ext.impl.wxpay.dto.OrderComplaintMediaDto;

import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author HlpayTeam
 * @date 2024/10/09 11:37
 */

@Data
@ExcelIgnoreUnannotated
public class OrderComplaintExport {

    @ExcelProperty("商户号")
    @ColumnWidth(20)
    @Schema(description = "商户商户号")
    private String sn;

    @ExcelProperty("商户名称")
    @ColumnWidth(20)
    @Schema(description = "商户名称")
    private String snName;

    @ExcelProperty("投诉单号")
    @ColumnWidth(30)
    @Schema(description = "投诉单号")
    private String complaintId;

    @ExcelProperty("平台订单号")
    @ColumnWidth(30)
    @Schema(description = "平台订单号")
    private String payOrderNo;

    @ExcelProperty("商户订单号")
    @ColumnWidth(30)
    @Schema(description = "商户订单号")
    private String mchOrderNo;

    @ExcelProperty("微信订单号")
    @ColumnWidth(30)
    @Schema(description = "微信订单号")
    private String wxOrderNo;

    /**
     * PENDING-待处理 0
     * PROCESSING-处理中 1
     * PROCESSED-已处理完成 2
     */
    @Schema(description = "投诉状态'")
    private Integer status;

    @ExcelProperty("投诉状态")
    @ColumnWidth(10)
    private String statusText;

    @ExcelProperty("服务商编码")
    @ColumnWidth(15)
    @Schema(description = "默认服务商")
    private String providerCode;

    @ExcelProperty("服务商名称")
    @ColumnWidth(20)
    @TableField(exist = false)
    @Schema(description = "默认服务商")
    private String providerName;

    @Schema(description = "渠道编码")
    private String channelCode;

    @ExcelProperty("渠道名称")
    @ColumnWidth(15)
    @TableField(exist = false)
    @Schema(description = "渠道名称")
    private String channelName;

    @ExcelProperty("微信商户号")
    @ColumnWidth(15)
    @Schema(description = "商户号")
    private String appId;

    @ExcelProperty("联系人手机号")
    @ColumnWidth(15)
    @Schema(description = "联系人手机号")
    private String phone;

    @ExcelProperty("金额")
    @ColumnWidth(10)
    @Schema(description = "金额")
    private BigDecimal amount;

    @ExcelProperty("投诉次数")
    @ColumnWidth(10)
    @Schema(description = "投诉次数")
    private Integer num;

    @ExcelProperty("投诉详情")
    @ColumnWidth(20)
    @Schema(description = "投诉详情")
    private String detail;

    @ExcelProperty("问题描述")
    @ColumnWidth(20)
    @Schema(description = "问题描述")
    private String problemDesc;
    /**
     * REFUND: 申请退款
     * SERVICE_NOT_WORK: 服务权益未生效
     * OTHERS: 其他类型
     */
    @ExcelProperty("问题类型")
    @ColumnWidth(10)
    @Schema(description = "问题类型")
    private String problemType;

    @ExcelProperty("申请退款金额")
    @ColumnWidth(10)
    @Schema(description = "申请退款金额")
    private BigDecimal refundAmount;

    @TableField(exist = false)
    @Schema(description = "投诉图片微信MediaId集合")
    private List<OrderComplaintMediaDto> complaintMedias;

    @Schema(description = "投诉图片地址")
    private String complaintMediaJson;

    @ExcelProperty("是否有退款")
    @ColumnWidth(10)
    @Schema(description = "是否有退款")
    private Integer refunded;

    @ExcelProperty("是否有留言")
    @ColumnWidth(10)
    @Schema(description = "是否有留言")
    private Integer response;

    @ExcelProperty("是否平台介入")
    @ColumnWidth(10)
    @Schema(description = "是否平台介入")
    private Integer platform;


    /**
     * REFUND: 申请退款
     * SERVICE_NOT_WORK: 服务权益未生效
     * OTHERS: 其他类型
     */
    public String getProblemType() {
        String text = null;
        if(StrUtil.isNotEmpty(this.problemType)){
            switch (this.problemType){
                case "REFUND":
                    text = "待处理";
                    break;
                case "SERVICE_NOT_WORK":
                    text = "服务权益未生效";
                    break;
                case "OTHERS":
                    text = "其他类型";
                    break;
            }
        }
        if(text == null){
            text = this.problemType;
        }
        return text;
    }

    public String getStatusText() {
        String text = null;
        if(this.status != null){
            switch (this.status){
                case 0:
                    text = "待处理";
                    break;
                case 1:
                    text = "处理中";
                    break;
                case 2:
                    text = "处理完成";
                    break;
            }
        }
        return text;
    }
}
